﻿package lib 
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	/**
	 * ...
	 * @author kabuto.boy
	 */
	public class CustomButton extends MovieClip
	{
		public var up:Object;
		public var down:Object;
		public var over:Object;
		
		public function CustomButton($up:Object, $down:Object, $over:Object) 
		{
			up = $up;
			down = $down;
			over = $over;
			
			this.addEventListener(MouseEvent.MOUSE_DOWN, onEvent);
			this.addEventListener(MouseEvent.MOUSE_UP, onEvent);
			this.addEventListener(MouseEvent.ROLL_OVER, onEvent);
			this.addEventListener(MouseEvent.ROLL_OUT, onEvent);
			
			this.gotoAndStop(up);
		}
		
		private function onEvent(event:*):void
		{
			switch(event.type) {
				case "mouseDown" :
					this.gotoAndStop(down);
					break;
				case "mouseUp" :
					this.gotoAndStop(up);
					break;
				case "rollOver" :
					this.gotoAndStop(over);
					break;
				case "rollOut" :
					this.gotoAndStop(up);
					break;
			}
		}
		
	}

}